import {
  IsString,
  IsNumber,
  IsOptional,
  IsEnum,
  IsArray,
  Min,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class CreateProductDto {
  @ApiProperty({ description: '商品标题' })
  @IsString()
  title: string;

  @ApiPropertyOptional({ description: '商品描述' })
  @IsString()
  @IsOptional()
  description?: string;

  @ApiProperty({ description: '商品价格' })
  @IsNumber()
  @Min(0)
  price: number;

  @ApiPropertyOptional({ description: '原价' })
  @IsNumber()
  @Min(0)
  @IsOptional()
  originalPrice?: number;

  @ApiPropertyOptional({ description: 'VIP价格' })
  @IsNumber()
  @Min(0)
  @IsOptional()
  vipPrice?: number;

  @ApiPropertyOptional({ description: 'SVIP价格' })
  @IsNumber()
  @Min(0)
  @IsOptional()
  svipPrice?: number;

  @ApiPropertyOptional({ description: '封面图URL' })
  @IsString()
  @IsOptional()
  cover?: string;

  @ApiPropertyOptional({ description: '图片列表', type: [String] })
  @IsArray()
  @IsOptional()
  images?: string[];

  @ApiPropertyOptional({ description: '文件URL' })
  @IsString()
  @IsOptional()
  fileUrl?: string;

  @ApiPropertyOptional({ description: '文件大小（字节）' })
  @IsNumber()
  @IsOptional()
  fileSize?: number;

  @ApiPropertyOptional({ description: '分类ID' })
  @IsString()
  @IsOptional()
  categoryId?: string;

  @ApiPropertyOptional({ description: '标签', type: [String] })
  @IsArray()
  @IsOptional()
  tags?: string[];

  @ApiPropertyOptional({
    description: '最低会员要求',
    enum: ['free', 'vip', 'svip'],
  })
  @IsEnum(['free', 'vip', 'svip'])
  @IsOptional()
  minMembership?: 'free' | 'vip' | 'svip';

  @ApiPropertyOptional({ description: '是否推荐' })
  @IsOptional()
  isFeatured?: boolean;

  @ApiPropertyOptional({ description: '是否热门' })
  @IsOptional()
  isHot?: boolean;

  @ApiPropertyOptional({ description: '排序权重' })
  @IsNumber()
  @IsOptional()
  sort?: number;
}
